﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Net.Sockets;

namespace libReadWrite
{
    public class BigEndianReaderForWifi: BigEndianReader
    {
        private Socket socket;

        public BigEndianReaderForWifi(Socket in_socket)
        {
            this.socket = in_socket;
        }

        //Return little endian bytes
        public override byte[] ReadBigEndianBytes(int count)
        {
            byte[] bytes = new byte[count];

            for (int i = count - 1; i >= 0; i--)
            {
                bytes[i] = ReadByte();
            }

            return bytes;
        }

        public override byte ReadByte()
        {
            byte[] buffer_1B = new byte[1];
            byte b;

            SocketController.Receive(socket, buffer_1B, 0, 1);

            b = buffer_1B[0];
            
            return b;
        }

        public override byte[] ReadBytes(int count)
        {
            byte[] buffer = new byte[count];

            SocketController.Receive(socket, buffer, 0, count);

            return buffer;
        }

        public override void Close()
        {
            throw new NotImplementedException();
        }
    }
}
